import request from '@/utils/request/request';
import {
  RoleAuthParams,
  UserAuthParams,
  UserBatchAuthParams,
  DeptAuthParams,
} from './model/permissionModel';

// 根据角色获取菜单权限
export function queryRoleAuthList(roleId: string) {
  return request.get('/api/system/permission/list-role-resources', {
    params: { roleId },
  });
}

// 角色授权菜单
export function updateRoleAuth(data: RoleAuthParams) {
  return request.post('/api/system/permission/assign-role-menu', data);
}

// 根据用户获取角色权限
export function queryUserRoleList(userId: string) {
  return request.get('/api/system/permission/list-user-roles', {
    params: { userId },
  });
}

// 用户授权角色
export function updateUserRole(data: UserAuthParams) {
  return request.post('/api/system/permission/assign-user-role', data);
}

// 为批量用户授权角色
export function batchUpdateUserRole(data: UserBatchAuthParams) {
  return request.post('/api/system/permission/assign-users-role', data);
}

// 通过组织机构向批量用户授权角色
export function updateUserRoleByDept(data: DeptAuthParams) {
  return request.post('/api/system/permission/assign-dept-role', data);
}
